<template>
  <div>
    <div class="content" style="width: 800px">
      <dl class="company_center_content">
        <dt>
          <h1>
            <em></em>
            修改职位：{{position.positionName}}
          </h1>
        </dt>
        <dd>

          <div class="ccc_tr">上次更新： {{makeDate(this.position.updateTime)}}<span>|</span>招聘就在 <span>易小聘~</span> </div>
          <el-form id="jobForm" label-width="100px" class="demo-ruleForm" ref="basicResume"
                   :model="position" style="margin-left: 0px"
          >
            <table class="btm" style="width: 593px" >
              <el-row>
                <el-col :span="12">
                  <el-form-item label="职位类别" prop="region">
                    <jobClassify v-on:job="getJobClick"></jobClassify>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="职位名称" prop="region">
                    <el-input v-model="position.positionName" placeholder="如“产品经理”" style="width: 200px"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="所属部门" prop="region">
                    <el-input v-model="position.department" placeholder="请输入职位部门" style="width: 200px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="发布人" prop="region">
                    <el-input v-model="position.hrName" style="width: 200px" :disabled="true"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </table>
            <table class="btm">
              <el-form-item label="工作性质" prop="resource">
                <el-radio-group v-model="position.jobNature">
                  <el-radio label="全职"></el-radio>
                  <el-radio label="兼职"></el-radio>
                  <el-radio label="实习"></el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="月薪范围" prop="resource">
                <el-input v-model="position.minSalary" style="width: 200px" placeholder="最低月薪" ></el-input><span>k</span>
                <el-input v-model="position.maxSalary" style="width: 200px;margin-left: 30px" placeholder="最高月薪" ></el-input><span>k</span>
              </el-form-item>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="工作城市" prop="resource">
                    <el-input v-model="position.city"  placeholder="请输入工作城市:如“北京”" ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="招聘人数" prop="resource">
                    <el-input-number v-model="position.needNums" controls-position="right"  :min="1" ></el-input-number>
                  </el-form-item>
                </el-col>
              </el-row>

            </table>
            <table class="btm">
              <el-row style="margin-top: 20px">
                <el-col :span="12">
                  <el-form-item label="工作经验" prop="region">
                    <el-select v-model="position.workExp" placeholder="请选择工作经验">
                      <el-option label="在校" value="在校"></el-option>
                      <el-option label="应届生" value="应届生"></el-option>
                      <el-option label="1年以内" value="1年以内"></el-option>
                      <el-option label="1-3年" value="1-3年"></el-option>
                      <el-option label="3-5年" value="3-5年"></el-option>
                      <el-option label="5年之上" value="5年之上"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="学历" prop="degree">
                    <el-select v-model="position.eduRequirements" placeholder="请选择学历要求">
                      <el-option label="初中及以下" value="初中及以下"></el-option>
                      <el-option label="高中" value="高中"></el-option>
                      <el-option label="大专" value="大专"></el-option>
                      <el-option label="本科" value="本科"></el-option>
                      <el-option label="研究生" value="研究生"></el-option>
                      <el-option label="博士" value="博士"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item label="公司福利" prop="welfare">
                <el-input
                        type="textarea"
                        :autosize="{ minRows: 4, maxRows: 5}"
                        placeholder="如“不加班”、“扁平化管理，氛围好”、“发展前景好”"
                        v-model="position.welfare">
                </el-input>
              </el-form-item>
              <el-form-item label="职位描述" prop="welfare">
                <el-input
                        type="textarea"
                        :autosize="{ minRows: 4, maxRows: 5}"
                        placeholder="建议分条填写工作职责、工作要求"
                        v-model="position.workDescription">
                </el-input>
              </el-form-item>
              <el-form-item>
                <span>工作地址：{{position.positionAddress}}</span>
                <el-button type="info" @click="showBaiduMap()">点击添加工作地址</el-button>
              </el-form-item>
            </table>
            <a class="btn_32" @click="updatePosition()">保存修改</a>
            <a class="btn_32" @click="selPositionById()">重置</a>
          </el-form>
        </dd>
      </dl>
    </div>
    <!--弹窗：预览简历-->
    <el-dialog :visible.sync="visible1" style="width: 1700px;margin-left: -100px">
      <baiduMap v-on:addressAddByChild="addressAdd"></baiduMap>
    </el-dialog>
  </div>
</template>

<script>
  import jobClassify from '../jobclassify/Jobclassify'
  import {makeDate} from "../../common/js/dateformat"
  import baiduMap from '../baiduMap/baiduMap'
  export default {
    name: "update-position",
    data(){
      return{
        visible1:false,
        position:{
          positionId:'',
          businessName:'',
          hrName: '',
          positionName:'',
          eduRequirements:'',
          minSalary:'',
          maxSalary: '',
          needNums:'',//需求人数
          jobNature:'',
          jobclassify: '',
          welfare: '',
          city:'',
          workExp: '',
          department: '',
          workDescription: '',
          jd:'',
          wd:'',
          positionAddress:'',
        }
      }
    },
    components: {
      jobClassify,
      baiduMap
    },
    created(){
      this.position.positionId= this.$route.params.positionId;
      this.selPositionById();
    },
    methods: {
      selPositionById(){
        this.$ajax.post(this.$config.url+"position/selPositionById", {
        "positionId":this.position.positionId
        }).then(res => {
          console.log(res.data.message);
          if(res.data.message==="succ"){
            this.position=res.data.object;
          }else{
            this.$message.error("出错了，无这个职位信息")
          }
        })
      },
      getJobClick(getJobClick){
        this.position.jobclassify=getJobClick;
      },
      updatePosition(){
        this.$ajax.post(this.$config.url+"position/updatePosition", this.position).then(res => {
          console.log(res.data.message);
          if(res.data==="succ"){
            this.$message.success("修改成功")
            this.selPositionById();
          }else{
            this.$message.error("出错了，更新失败")
          }
        })
      },
      makeDate(date){
        return makeDate(date)
      },
      showBaiduMap(){
        this.visible1=!this.visible1;
      },
      addressAdd(getPositionAddress){
        this.$message.success("已添加成功！可关闭该页面")
        console.log(getPositionAddress);
        this.position.jd=getPositionAddress.jd;
        this.position.wd=getPositionAddress.wd;
        this.position.positionAddress=getPositionAddress.site;
      }
    }

  }
</script>

<style scoped>
  .company_center_content{background-color:#fafafa;margin-top:5px;position:relative}
  .company_center_content>dt{height:47px;position:absolute;z-index:1;top:-5px;left:40px;background-color:#91cebe}
  .company_center_content>dt h1{color:#fff;font-size:24px;font-weight:normal;line-height:47px;padding:0 20px;margin:0}
  .company_center_content>dt em{background:url(img/title_arrow_new.png) no-repeat;width:4px;height:5px;position:absolute;left:-4px;top:0}
  span{font-size:20px}
  .company_center_content>dd{min-height:337px;padding:70px 0;position:relative}
  .company_center_content>dd .ccc_tr{position:absolute;right:20px;top:20px}
  .company_center_content>dd .ccc_tr span{color:#019875;font-weight:600}
  .company_center_content .no_resume_tip{font-size:18px;min-height:65px;background:url(img/noresult_95.png) 140px 0 no-repeat;padding:70px 0 0 250px;margin-top:15px;line-height:32px}
  .company_center_content .pt35{padding-top:70px !important}
  .company_center_content .no_resume_tip span{font-size:14px;color:#999}
  .company_center_content .no_resume_tip a{color:#019875;text-decoration:underline}
  .btm{border-bottom:1px solid #e0e0e0}
  .btn_32{padding: 0 55px;font-size: 18px;color: #fff;border: none;height: 32px;line-height: 32px;background: #91cebe;float: left;margin-left: 120px ;overflow: hidden;transition:background 0.2s ease-in 0s;}
  .btn_32:hover{color:#fff;background:#019875;}
</style>